Skip to main content

ps command

ps - report a snapshot of the current processes.

The ps command in Linux is a utility used to display information about running processes on your system. It’s essential for monitoring system activity, troubleshooting, or finding process IDs (PIDs) to manage tasks.

Usage: ps [options]

  • options: Flags that control what processes to show and how to display them.

  • No options shows minimal info about your current shell’s processes.

    Common Options

    OptionDescription
    -eShow all processes
    -fFull-format listing
    -uFilter by user
    -oCustom output columns
    auxBSD-style detailed list (no dash)
    -pShow specific PID (e.g., -p 1234)

Examples

  • Basic Usage

    Run ps without options to see processes tied to your current terminal.

    ps
    • Output (example):
        PID TTY          TIME CMD
      1234 pts/0 00:00:00 bash
      5678 pts/0 00:00:00 ps
    • Explanation:
      • PID: Process ID.
      • TTY: Terminal associated with the process.
      • TIME: CPU time used.
      • CMD: Command that started the process.
  • Showing All Processes

    Use -e (everything) or -A to list all running processes on the system.

    ps -e
    • Output (partial):
        PID TTY          TIME CMD
      1 ? 00:00:01 systemd
      2 ? 00:00:00 kthreadd
      123 ? 00:00:00 sshd
  • Adding More Details

    Use -f (full-format) for more columns like user, parent PID, and start time.

    ps -ef
    • Output (partial):
      UID        PID  PPID  C STIME TTY          TIME CMD
      root 1 0 0 10:00 ? 00:00:01 /sbin/init
      root 123 1 0 10:01 ? 00:00:00 /usr/sbin/sshd
      alice 4567 123 0 10:02 pts/0 00:00:00 bash
    • Explanation:
      • UID: User running the process.
      • PPID: Parent process ID.
      • C: CPU usage percentage.
      • STIME: Start time.
  • Customizing Output

    Use -o (output format) to select specific columns.

    ps -eo pid,user,cmd
    • Output:
        PID USER     CMD
      1 root /sbin/init
      123 root /usr/sbin/sshd
      4567 alice bash
    • Common fields: pid, user, cmd, pcpu (CPU %), pmem (memory %).
  • Filtering by User

    Use -u to show processes for a specific user.

    ps -u alice
    • Output:
        PID TTY          TIME CMD
      4567 pts/0 00:00:00 bash
      4589 pts/0 00:00:01 vim
  • Process Tree View

    Use aux (BSD-style) with ps for a detailed, user-friendly list, often paired with grep.

    ps aux
    • Output (partial):
      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
      root 1 0.0 0.1 123456 7890 ? Ss 10:00 0:01 /sbin/init
      alice 4567 0.0 0.2 234567 12345 pts/0 Ss 10:02 0:00 bash
    • Explanation:
      • %CPU, %MEM: Resource usage.
      • VSZ, RSS: Virtual and resident memory.
      • STAT: Process state (e.g., S = sleeping, R = running).

    Filter with grep:

    ps aux | grep firefox
    • Finds Firefox processes.
ps --help

Usage:
ps [options]

Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.

For more details, check the manual with man ps